from ..database import database, TABLE_PREFIX

from peewee import *
import datetime


class Service(database.Model):
    id = CharField(primary_key=True, max_length=40, db_column='id')
    screen_name = CharField(db_column='screen_name', help_text='显示名称')
    short_name = CharField(db_column='short_name', help_text='短名称')
    fee = DecimalField(decimal_places=4, db_column='fee', help_text='服务费')
    mode = CharField(db_column='mode', help_text='服务计费方式', default='fixed')
    created_at = DateTimeField(db_column='created_at', help_text='创建时间', default=datetime.datetime.now)
    updated_at = DateTimeField(db_column='updated_at', help_text='更新时间', default=datetime.datetime.now)

    # class Meta:
    #     db_table = '{}_services'.format(TABLE_PREFIX)

    def is_fixed_mode(self):
        return self.mode == 'fixed'
